


LyLock_Enslave = { }
table.insert(LyLock_Plugins, LyLock_Enslave)
LyLock_Enslave.Frame = "LyLockEnslaveFrame"
LyLock_Enslave.Events = {
    "UNIT_SPELLCAST_SENT",
    "UNIT_SPELLCAST_FAILED",
    "UNIT_SPELLCAST_INTERRUPTED"
}



--------------------------------------------------------------------------------------
-- Enslave Functions -----------------------------------------------------------------
--------------------------------------------------------------------------------------
enslaveName = ""
enslaveShow = 0

LyLock_Enslave.ShowTimer = function()
    if (DBM) then
        LyLock_Enslave.DBMTimer = {}
        LyLock_Enslave.DBMTimer.EnslaveTimerText = UnitName("player").."'s Demon"
        LyLock_Enslave.DBMTimer.EnslaveTimerMin = 5
        LyLock_Enslave.DBMTimer.EnslaveTimerSec = 0
        if( DBM.Rank > 0 ) then
        else
            --LyLock_Enslave.DBMTimer.EnslaveTimerBroadcast = false;
        end

        DBM.StartStatusBarTimer(
            ((LyLock_Enslave.DBMTimer.EnslaveTimerMin * 60 ) +
              LyLock_Enslave.DBMTimer.EnslaveTimerSec),
            LyLock_Enslave.DBMTimer.EnslaveTimerText, 
            not LyLock_Enslave.DBMTimer.EnslaveTimerBroadcast
        )
        if ((LyLock_Enslave.DBMTimer.EnslaveTimerMin * 60 ) + LyLock_Enslave.DBMTimer.EnslaveTimerSec) > 10 then 
            if LyLock_Enslave.DBMTimer.EnslaveTimerBroadcast then
                DBM.Schedule(((LyLock_Enslave.DBMTimer.EnslaveTimerMin * 60 ) + LyLock_Enslave.DBMTimer.EnslaveTimerSec) - 10, "DBM.Announce", string.format(DBM_TIMER_IS_ABOUT_TO_EXPIRE, LyLock_Enslave.DBMTimer.EnslaveTimerText));
            else
                DBM.Schedule(((LyLock_Enslave.DBMTimer.EnslaveTimerMin * 60 ) + LyLock_Enslave.DBMTimer.EnslaveTimerSec) - 10, "DBM.AddSpecialWarning", string.format(DBM_TIMER_IS_ABOUT_TO_EXPIRE, LyLock_Enslave.DBMTimer.EnslaveTimerText));
            end
        end    
    
    end
end

LyLock_Enslave.OnEvent = function()
    if event=="UNIT_SPELLCAST_SENT" then
        if (arg1=="player") and (arg2==WORD_ENSLAVEDEMON) then
            enslaveName = arg4
            enslaveShow = 1
        end
    elseif event=="UNIT_SPELLCAST_INTERRUPTED" or event=="UNIT_SPELLCAST_FAILED" then
        enslaveName = ""
        enslaveShow = 0
    elseif event=="UNIT_AURA" then
    
    elseif event=="UNIT_SPELLCAST_START" then
    
    elseif event=="UNIT_SPELLCAST_STOP" then
    
    end
end
LyLock_Enslave.OnHalfSecond = function()
    if enslaveShow == 1 then
        if (UnitName("pet")==enslaveName) then
            enslaveShow = 2
            LyLock_Enslave.ShowTimer()
        end
    elseif enslaveShow == 2 then
        
    end
end



LyLock_Enslave.OnSecond = function()


end



